package com.yupi.yuso.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yupi.yuso.manager.CrawlerManager;
import com.yupi.yuso.model.dto.picture.PictureQueryRequest;
import com.yupi.yuso.model.vo.PictureVO;
import com.yupi.yuso.service.PictureService;
import org.elasticsearch.common.recycler.Recycler;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author vvv
 * @date 2023-12-20 13 36
 * discription
 */
@Service
public class PictureServiceImpl implements PictureService {

    @Resource
    private CrawlerManager crawlerManager;

    @Override
    public Page<PictureVO> listPictureVOByPage(PictureQueryRequest pictureQueryRequest) {
        long current = pictureQueryRequest.getCurrent();
        long size = pictureQueryRequest.getPageSize();
        String searchText = pictureQueryRequest.getSearchText();

        List<PictureVO> pictureVOList = crawlerManager.crawlPicture(current, searchText);
        Page<PictureVO> pictureVOPage = new Page<>(current, size, CrawlerManager.CRAWL_TOTAL);
        pictureVOPage.setRecords(pictureVOList);
        return pictureVOPage;
    }
}
